<template>
  <div class="ele-body">
    <el-card shadow="never">
      <!-- 数据表格 -->
      <ele-pro-table
        ref="table"
        :datasource="url"
        :columns="columns"
        :where="where"
        height="calc(100vh - 315px)">
        <template slot="toolbar">
          <el-button
            @click="openEdit(null)"
            type="primary"
            icon="el-icon-plus"
            class="ele-btn-icon"
            size="small"
            v-if="permission.includes('sys:channel:add')">添加
          </el-button>

        </template>
        <!-- 表头工具栏 -->
        <!--        <template slot="toolbar">-->
        <!--          <el-button-->
        <!--            @click="exportData"-->
        <!--            type="primary"-->
        <!--            icon="el-icon-download"-->
        <!--            class="ele-btn-icon"-->
        <!--            size="small"-->
        <!--            v-if="permission.includes('sys:loginlog:export')">导出-->
        <!--          </el-button>-->
        <!--        </template>-->
        <!-- 操作类型列 -->
        <!-- 操作列 -->
        <template slot="action" slot-scope="{row}">
          <el-link
            type="primary"
            :underline="false"
            icon="el-icon-edit"
            @click="openEdit(row)"
            v-if="permission.includes('sys:channel:edit')">修改
          </el-link>

        </template>
      </ele-pro-table>
    </el-card>

    <!-- 编辑弹窗 -->
    <channel-edit
      :data="current"
      :visible.sync="showEdit"
      @done="reload"/>
  </div>
</template>

<script>
import {mapGetters} from "vuex";
import ChannelEdit from './exchange-edit.vue';


export default {
  name: 'SystemExchange',
  components: { ChannelEdit},
  computed: {
    ...mapGetters(["permission"]),
  },
  data() {
    return {
      // 表格数据接口
      url: '/admin/config.exchangeconfig/index',
      // 表格列配置
      columns: [
        {
          columnKey: 'selection',
          type: 'selection',
          width: 45,
          align: 'center',
          fixed: "left"
        },
        {
          prop: 'ID',
          label: 'ID',
          width: 60,
          align: 'center',
          showOverflowTooltip: true,
          fixed: "left"
        },
        // {
        //   prop: 'ChannelID',
        //   label: '子渠道ID',
        //   width: 60,
        //   align: 'center',
        //   showOverflowTooltip: true,
        //   fixed: "left"
        // },
        {
          prop: 'ProductName',
          label: '兑换渠道',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },
        {
          prop: 'ExchangeChannelName',
          label: '兑换类型',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },
        {
          prop: 'Sort',
          label: '排序',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },
        {
          prop: 'Nullity',
          label: '状态',
          align: 'center',
          showOverflowTooltip: true,
          minWidth: 100
        },
        {
          columnKey: 'action',
          label: '操作',
          width: 90,
          align: 'center',
          resizable: false,
          slot: 'action',
          fixed: "right"
        }
      ],
      // 表格搜索条件
      where: {},
      // 当前编辑数据
      current: null,
      // 是否显示编辑弹窗
      showEdit: false,
      // 筛选日期范围
      // daterange: null,
      // 日期时间选择器快捷项
    };
  },
  methods: {
    /* 刷新表格 */
    reload() {
      this.$refs.table.reload({where: this.where});
    },
    /* 重置搜索 */
    reset() {
      this.where = {};
      this.daterange = null;
      this.reload();
    },
    openEdit(row) {
      console.log(row)
      this.current = row;
      this.showEdit = true;
    },
    /* 日期选择改变回调 */
  }
}
</script>

<style scoped>
</style>
